/* 
*  Copyright (C) 2009-2010 WCG Project
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/



/*
*	Language Functions
*/

#define TOTAL_MENUS 15


// This is the list of menu titles that are in war3ft.txt
new const MENU_NAMES[TOTAL_MENUS][] = 
{
	"MENU_BUY_ITEM",
	"MENU_BUY_ITEM2",
	"MENU_SELECT_SKILL",
	"MENU_SELECT_ATTRIBUTE",
	"MENU_SELECT_CLASS",
	"MENU_WCGMENU",
	"MENU_SKILLS_OPTIONS",
	"MENU_ATTRIBUTES_OPTIONS",
	"MENU_ITEM_OPTIONS",
	"MENU_RACE_OPTIONS",
	"MENU_ADMIN_MENU",
	"MENU_GIVE_PLAYERS_XP",
	"MENU_TEAM_XP",
	"MENU_RESET_XP",
	"MENU_REPLACE_ITEM"
};

// Callback functions for the above menu names
new const MENU_CALLBACK[TOTAL_MENUS][] = 
{
	"_MENU_Shopmenu1",
	"_MENU_Shopmenu2",
	"_MENU_SelectSkill",
	"_MENU_SelectAttribute",
	"_MENU_ChangeClass",
	"_MENU_WCGMenu",
	"_menu_Skill_Options",
	"_menu_Attributes_Options",
	"_menu_Item_Options",
	"_menu_Race_Options",
	"_menu_Admin_Options",
	"_menu_PlayerXP_Options",
	"_menu_TeamXP_Options",
	"_MENU_ResetXP",
	"_menu_ReplaceItem"
};

/*
	Description: Function will register all menus for all languages
*/
public LANG_SetMenus()
{
	new iTotalLanguages = get_langsnum();
	new lang[3], menu[128];
	new curMenuId = -1, highestMenuId = -1;
	new iLang, iMenu;


	// Loop through every menu

	for ( iMenu = 0; iMenu < TOTAL_MENUS; iMenu++ )
	{
		// Register the menu names for each language

		for ( iLang = 0; iLang < iTotalLanguages; iLang++ )
		{
			get_lang ( iLang, lang );

			if ( lang_exists( lang ) )
			{
				formatex ( menu, 127, "%L", lang, MENU_NAMES[iMenu] );
				curMenuId = register_menuid ( menu );

				if ( curMenuId > highestMenuId )
				{
					register_menucmd ( curMenuId, 1023, MENU_CALLBACK[iMenu] );
					highestMenuId = curMenuId;
				}
			}
		}// End language loop
	}// End menu loop
}

//Function will return the race name based on the race id and the language of the user
LANG_GetClassName( race_id, id, race_name[], len )
{

	new szRaceHelper[64];
	
	formatex( szRaceHelper, 63, "CLASS_%d", race_id );

	// Lookup the race name
	formatex( race_name, len-1, "%L", id, szRaceHelper );
}

//Description: Function will return the shopmenu item name based on the item id and the language of the user
LANG_GetItemName ( item_id, id, item_name[], len, bool:shortLookup = false )
{
	
	if ( item_id < 0 )
	{
		return;
	}

	new szItemHelper[64];

	if ( shortLookup == true )
	{
		formatex( szItemHelper, 63, "ITEM_S_%d", item_id );
	}
	else
	{
		formatex( szItemHelper, 63, "ITEM_%d", item_id );
	}

	// Lookup the item name
	formatex( item_name, len, "%L", id, szItemHelper );
}

LANG_GetItemInfo( item_id, id, item_description[], len )
{
	switch ( item_id )
	{
		case ITEM_ANKH:			formatex ( item_description, len, "%L", id, "ITEM_I_0"  );
		case ITEM_BOOTS:		formatex ( item_description, len, "%L", id, "ITEM_I_1"  );
		case ITEM_CLAWS:		formatex ( item_description, len, "%L", id, "ITEM_I_2", get_pcvar_num( CVAR_claw ), get_pcvar_num( CVAR_claw ) );
		case ITEM_CLOAK:		formatex ( item_description, len, "%L", id, "ITEM_I_3" );
		case ITEM_MASK:			formatex ( item_description, len, "%L", id, "ITEM_I_4" );
		case ITEM_NECKLACE:		formatex ( item_description, len, "%L", id, "ITEM_I_5" );
		case ITEM_FROST:		formatex ( item_description, len, "%L", id, "ITEM_I_6" );
		case ITEM_HEALTH:		formatex ( item_description, len, "%L", id, "ITEM_I_7" );
		case ITEM_TOME:			formatex ( item_description, len, "%L", id, "ITEM_I_8" );
		case ITEM_SCROLL:		formatex ( item_description, len, "%L", id, "ITEM_I_9" );
		case ITEM_PROTECTANT:	formatex ( item_description, len, "%L", id, "ITEM_I_10" );
		case ITEM_HELM:			formatex ( item_description, len, "%L", id, "ITEM_I_11" );
		case ITEM_AMULET:		formatex ( item_description, len, "%L", id, "ITEM_I_12" );
		case ITEM_SOCK:			formatex ( item_description, len, "%L", id, "ITEM_I_13" );
		case ITEM_GLOVES:		formatex ( item_description, len, "%L", id, "ITEM_I_14", get_pcvar_num( CVAR_glove_timer ) );
		case ITEM_RING:			formatex ( item_description, len, "%L", id, "ITEM_I_15" );
		case ITEM_CHAMELEON:	formatex ( item_description, len, "%L", id, "ITEM_I_16" );
		case ITEM_MOLE:			formatex ( item_description, len, "%L", id, "ITEM_I_17" );

		default:				formatex ( item_description, len, " " );
	}
}

//Description: Function will return the skill name based on the race id, skill id and the language of the user
LANG_GetSkillName( skill_id, id, skill_name[], len, func_id = 0)
{
	static szTmp[16]

	if ( !IsValidSkill(skill_id) )
	{
		WC3_Log( true, "[%d] Invalid skill: %d", func_id, skill_id );
		return;
	}

	formatex ( szTmp, 15, "SKILL_%d", skill_id );
	formatex ( skill_name, len-1, "%L", id, szTmp );
}

LANG_GetSkillInfo( skill_id, id, skill_description[], len )
{
	static szTmp[16]
	
	formatex( szTmp, 15, "SKILL_I_%d", skill_id )
	formatex ( skill_description, len-1, "%L", id, szTmp )
}


LANG_GetAttributeName( iAttribID, id, szAttributeName[], len, iDebugID = 0)
{
	static szTmp[16]

	if ( !IsValidAttribute( iAttribID ) )
	{
		WC3_Log( true, "[LANG_GetAttributeName] Invalid attribute: %d [%d]", iAttribID, iDebugID )
		return
	}

	formatex ( szTmp, 15, "ATTRIB_%d", iAttribID )
	formatex ( szAttributeName, len-1, "%L", id, szTmp )
}


LANG_GetAttributeInfo( iAttribID, id, szAttributeDesc[], len )
{
	static szTmp[16]
	
	formatex( szTmp, 15, "ATTRIB_I_%d", iAttribID )
	formatex ( szAttributeDesc, len-1, "%L", id, szTmp )
}
